<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
  <title>Guide to Compositor</title>


  <style type="text/css">
img {
vertical-align: middle;
margin-top: 5px;
margin-bottom: 20px;
}
img.bordered {
border: 1px solid black;
}
h1,h2,h3 {
margin-top: 10pt;
margin-bottom: 10pt;
}
  </style>
</head>


<body>

<h1>Guide
to Compositor</h1>

<h3>by Wesley Crossman</h3>

<p>Compositor is a program which aims to make scripting simple
image
manipulations easy. It is intended to be a simple substitute
for ImageMagick, for a frequently-used subset of its features. It is
not as flexible, but it is far easier to use than
ImageMagick.</p>

<h2><a name="getting_started"></a>Getting
Started</h2>

The template of the XML file looks like this:<br>

<br>

<span style="font-family: monospace;">&lt;composite&gt;</span><br style="font-family: monospace;">

<span style="font-family: monospace; font-style: italic;">[tags
go here]</span><br style="font-family: monospace;">

<span style="font-family: monospace;">&lt;/composite&gt;</span><br>

<br>

To scale the image "hello.png" by 50% and save it to "hello50.png":<br>

<span style="font-family: monospace;" class="">&lt;composite&gt;</span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">&lt;file
dest="hello50.png"&gt;</span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">&nbsp;
&lt;image
value="hello.png"
scale="50%" primary="true" /&gt;</span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">&lt;/file&gt;</span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">&lt;/composite&gt;<br>

<img style="width: 69px; height: 66px;" alt="" src="hello.png"><img style="margin-left: 10px; margin-right: 10px; width: 60px; height: 30px;" alt="" src="arrow.png"><img style="width: 34px; height: 33px;" alt="" src="hello50.png"><br>

</span>To add a red background to "hello.png" and save it to
"hello.jpg":<br>

<span style="font-family: monospace;" class="">&lt;composite&gt;<br style="font-family: monospace;" class="">

</span><span style="font-family: monospace;" class="">
&lt;file dest="hello.jpg"&gt;<br>

</span><span style="font-family: monospace;" class="">&nbsp;
&lt;color value="#FF0000" /&gt;</span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">
&nbsp; &lt;image value="hello.png"&nbsp;primary="true"
/&gt;</span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">
&lt;/file&gt;</span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">
&lt;/composite&gt;<br>

</span><span style="font-family: monospace;" class=""><img style="width: 69px; height: 66px;" alt="" src="hello.png"><img style="margin-left: 10px; margin-right: 10px; width: 60px; height: 30px;" alt="" src="arrow.png"><img style="width: 69px; height: 66px;" alt="" src="hello.jpg"><br>

</span>The only thing that might need explaining is the "primary"
attribute.
It will set the destination file's size to the size of the attribute's
image,
unless you override this by setting "width" and/or "height" in the
&lt;file&gt; attribute itself. You always need to either
set&nbsp;primary="true" on an &lt;image&gt; inside each
&lt;file&gt; or give each file an explicit "height" and "width".
<h2><a name="transformations"></a>Transformations</h2>

<p>It's possible to do many things with just the
&lt;file&gt;,
&lt;image&gt;, and &lt;color&gt; attributes, but
sometimes you need to perform several modifications to a source image
before you use it. The XML standard doesn't give us enough flexibility
with just attributes, so we need to introduce new tags. These tags can
be children of &lt;image&gt; tags.</p>

<span style="font-style: italic;">Examples:</span><br>

<span style="font-family: monospace;" class="">&lt;composite&gt;<br style="font-family: monospace;" class="">

</span><span style="font-family: monospace;" class="">
&lt;file dest="hellotr1.png"&gt;</span><span style="font-family: monospace;" class=""></span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">
&nbsp; &lt;image
value="hello.png"&nbsp;primary="true"&gt;<br>

&nbsp; &nbsp; &lt;resize value="80%" /&gt;<br>

&nbsp; &nbsp; &lt;rotate value="-20" /&gt;<br>

&nbsp; &nbsp; &lt;flip value="vertical" /&gt;<br>

&nbsp; &lt;/image&gt;<br style="font-family: monospace;" class="">

</span><span style="font-family: monospace;" class="">
&lt;/file&gt;</span><br style="font-family: monospace;" class="">

<span style="font-family: monospace;" class="">
&lt;/composite&gt;<br>

</span><span style="font-family: monospace;" class=""><img style="width: 69px; height: 66px;" alt="" src="hello.png"><img style="margin-left: 10px; margin-right: 10px; width: 60px; height: 30px;" alt="" src="arrow.png"><img style="width: 70px; height: 69px;" alt="" src="hellotr1.png"><br>

</span>
<h4>&lt;rotate&gt;</h4>

<p>Rotate has one attribute, value. You can use the angle in
degrees,
"left" for -90, or "right" for 90. Angles which are multiples of 90
should be totally crisp, but other angles will be slightly blurred and
will enlarge the source image.</p>

<span style="font-style: italic;">Examples:</span><br>

<span style="font-family: monospace;">Original</span><br>

<img style="width: 69px; height: 66px;" class="bordered" alt="" src="hello.png"><span style="font-family: monospace;" class=""></span><br>

<span style="font-family: monospace;">&lt;rotate
value="30" /&gt;<br>

<img style="width: 93px; height: 92px;" class="bordered" alt="" src="hellorotate1.png"><br style="font-family: monospace;">

</span><span style="font-family: monospace;">&lt;rotate
value="right"
/&gt;<br>

<img style="width: 66px; height: 69px;" class="bordered" alt="" src="hellorotate2.png"></span>
<h4>&lt;flip&gt;</h4>

<p>Flip has one attribute, value. It can be "vertical" or
"horizontal".</p>

<span style="font-style: italic;">Examples:</span><br>

<span style="font-family: monospace;">&lt;flip
value="vertical" /&gt;<br>

<img style="width: 69px; height: 66px;" alt="" src="helloflip.png"><br>

</span><span style="font-family: monospace;"></span>
<h4>&lt;crop&gt;</h4>

<p>Crop has one attribute, value. It should be in the form of
topleft-x,
topleft-y, width, height.</p>

<span style="font-style: italic;">Examples:</span><br>

<span style="font-family: monospace;">&lt;crop
value="5,5,30,40" /&gt;<br>

<img style="width: 30px; height: 40px;" alt="" src="hellocrop.png"></span>
<h4>&lt;resize&gt;</h4>

<p>Resize has one attribute, value.</p>

<span style="font-style: italic;">Examples:</span><br>

<span style="font-family: monospace;">&lt;resize
value="40%" /&gt;<br>

Scales to the equivalent of 40%,40%<br>

<img style="width: 27px; height: 26px;" alt="" src="helloresize1.png"> &nbsp;27 x 26<br style="font-family: monospace;">

</span><span style="font-family: monospace;">&lt;resize
value="30%,20%" /&gt;<br>

<img style="width: 20px; height: 13px;" alt="" src="helloresize2.png"> 20 x 13<br>

&lt;resize value="150,40" /&gt;<br>

<img style="width: 150px; height: 40px;" alt="" src="helloresize3.png"> 150 x 40<br>

</span><span style="font-family: monospace;">&lt;resize
value="50 w"
/&gt;<br>

Scales to 50 width, maintaining the&nbsp;aspect ratio<br>

<img style="width: 50px; height: 47px;" alt="" src="helloresize4.png"> 50 x 47<br>

&lt;resize value="50 h" /&gt;<br>

</span><span style="font-family: monospace;">Scales
to 50 height,
maintaining the&nbsp;aspect ratio</span><br>

<span style="font-family: monospace;"><img style="width: 52px; height: 50px;" alt="" src="helloresize5.png"> 52 x 50<br>

</span><span style="font-family: monospace;">&lt;resize
value="50 min"
/&gt;<br>

</span><span style="font-family: monospace;">Scales
the smaller
dimension to 50, maintaining the&nbsp;aspect ratio</span><br>

<span style="font-family: monospace;"><img style="width: 52px; height: 50px;" alt="" src="helloresize5.png"> 52 x 50</span><br>

<span style="font-family: monospace;">&lt;resize
value="50 max" /&gt;<br>

</span><span style="font-family: monospace;">Scales
the larger
dimension to 50, maintaining the&nbsp;aspect ratio</span><br>

<span style="font-family: monospace;"><img style="width: 50px; height: 47px;" alt="" src="helloresize4.png"> 50 x 47 </span><br>

<span style="font-family: monospace;"><br>

</span><span style="font-family: monospace;" class=""></span>
</body>
</html>
